/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
* File Name          : stm32f10x_it.c
* Author             : MCD Application Team
* Version            : V2.0.1
* Date               : 06/13/2008
* Description        : Main Interrupt Service Routines.
*                      This file provides template for all exceptions handler
*                      and peripherals interrupt service routine.
********************************************************************************
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/

/* Includes ------------------------------------------------------------------*/

#include "HAllInc.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
void NOP(void)
{
    //NOP
}
/**
  * @brief  This function handles NMI exception.
  * @param  None
  * @retval None
  */
void NMI_Handler(void)
{
}

/**
  * @brief  This function handles Hard Fault exception.
  * @param  None
  * @retval None
  */
void HardFault_Handler(void)
{
    /* Go to infinite loop when Hard Fault exception occurs */
    while (1)
    {
    }
}

/**
  * @brief  This function handles Memory Manage exception.
  * @param  None
  * @retval None
  */
void MemManage_Handler(void)
{
    /* Go to infinite loop when Memory Manage exception occurs */
    while (1)
    {
    }
}

/**
  * @brief  This function handles Bus Fault exception.
  * @param  None
  * @retval None
  */
void BusFault_Handler(void)
{
    /* Go to infinite loop when Bus Fault exception occurs */
    while (1)
    {
    }
}

/**
  * @brief  This function handles Usage Fault exception.
  * @param  None
  * @retval None
  */
void UsageFault_Handler(void)
{
    /* Go to infinite loop when Usage Fault exception occurs */
    while (1)
    {
    }
}

/**
  * @brief  This function handles SVCall exception.
  * @param  None
  * @retval None
  */
void SVC_Handler(void)
{
}

/**
  * @brief  This function handles Debug Monitor exception.
  * @param  None
  * @retval None
  */
void DebugMon_Handler(void)
{
}

/**
  * @brief  This function handles PendSVC exception.
  * @param  None
  * @retval None
  */
void PendSV_Handler(void)
{
}

/*******************************************************************************
* Function Name  : SysTickHandler
* Description    : This function handles SysTick Handler.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void SysTick_Handler(void)
{
    uchar i;
    /* Clear SysTick Counter */
    //1s soft time
    if (ucFlag1s == 0)
    {
        uiSysCnt++;
        if (uiSysCnt >= 1000)
        { //1000
            uiSysCnt = 0;
            ucFlag1s = 1;
        }
    }
    //
    if (uiTimeDelaymsCnt)
        uiTimeDelaymsCnt--;
    //soft timer
    if (ucTimeTenmSecFlag == 0)
    {
        ucTimeTenmSecCnt++;
        if (ucTimeTenmSecCnt >= 10)
        { //10
            ucTimeTenmSecCnt = 0;
            ucTimeTenmSecFlag = 1;
        }
    }

    //time delay
    if (uiOutDD)
        uiOutDD--;
    //usart1,usart2 timeout and time in
    for (i = 0; i < MAX_UART_NUM; i++)
    {
        //10ms soft time
        if (UsartTime10msFlag(i) == 0)
        {
            UsartTime10msCnt(i)++;
            if (UsartTime10msCnt(i) > 10)
            { //10
                UsartTime10msCnt(i) = 0;
                UsartTime10msFlag(i) = 1;
            }
        }
        //usart check time out
        if (UsartRStatus(i) > 0)
        {
            UsartTimeOut(i)++;
            if (UsartTimeOut(i) > 2000)
            { //2000
                UsartTimeOut(i) = 0;
                UsartRStatus(i) = 0;
            }
        }
        else
        {
            UsartTimeOut(i) = 0;
        }
        //
        if (UsartTimeInFlag(i) == 1)
        {
            if (UTime4sCnt(i))
            {
                UTime4sCnt(i)--;
            }
            else
            {
                UsartTimeInFlag(i) = 0;
            }
        }
    }
    //
    if ((GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 1) && (ucInputCNT[0] < 10))
    { //GPIOE, GPIO_Pin_2
        ucInputCNT[0]++;
    }
    if ((GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 0) && (ucInputCNT[0] != 0))
    { //GPIOE, GPIO_Pin_2
        ucInputCNT[0]--;
    }
    //
    if ((x0 == 1) && (ucInputCNT[0] > 7))
    {
        x0 = 0;
    }
    if ((x0 == 0) && (ucInputCNT[0] < 3))
    {
        x0 = 1;
    }
}

/*******************************************************************************
* Function Name  : WWDG_IRQHandler
* Description    : This function handles WWDG interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void WWDG_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : PVD_IRQHandler
* Description    : This function handles PVD interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void PVD_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : TAMPER_IRQHandler
* Description    : This function handles Tamper interrupt request. 
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void TAMPER_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : RTC_IRQHandler
* Description    : This function handles RTC global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void RTC_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : FLASH_IRQHandler
* Description    : This function handles Flash interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void FLASH_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : RCC_IRQHandler
* Description    : This function handles RCC interrupt request. 
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void RCC_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : EXTI0_IRQHandler
* Description    : This function handles External interrupt Line 0 request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void EXTI0_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : EXTI1_IRQHandler
* Description    : This function handles External interrupt Line 1 request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void EXTI1_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : EXTI2_IRQHandler
* Description    : This function handles External interrupt Line 2 request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void EXTI2_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : EXTI3_IRQHandler
* Description    : This function handles External interrupt Line 3 request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void EXTI3_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : EXTI4_IRQHandler
* Description    : This function handles External interrupt Line 4 request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void EXTI4_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : DMA1_Channel1_IRQHandler
* Description    : This function handles DMA1 Channel 1 interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void DMA1_Channel1_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : DMA1_Channel2_IRQHandler
* Description    : This function handles DMA1 Channel 2 interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void DMA1_Channel2_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : DMA1_Channel3_IRQHandler
* Description    : This function handles DMA1 Channel 3 interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void DMA1_Channel3_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : DMA1_Channel4_IRQHandler
* Description    : This function handles DMA1 Channel 4 interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void DMA1_Channel4_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : DMA1_Channel5_IRQHandler
* Description    : This function handles DMA1 Channel 5 interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void DMA1_Channel5_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : DMA1_Channel6_IRQHandler
* Description    : This function handles DMA1 Channel 6 interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void DMA1_Channel6_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : DMA1_Channel7_IRQHandler
* Description    : This function handles DMA1 Channel 7 interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void DMA1_Channel7_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : ADC1_2_IRQHandler
* Description    : This function handles ADC1 and ADC2 global interrupts requests.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void ADC1_2_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : USB_HP_CAN_TX_IRQHandler
* Description    : This function handles USB High Priority or CAN TX interrupts 
*                  requests.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void USB_HP_CAN_TX_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : USB_LP_CAN_RX0_IRQHandler
* Description    : This function handles USB Low Priority or CAN RX0 interrupts 
*                  requests.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void USB_LP_CAN_RX0_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : CAN_RX1_IRQHandler
* Description    : This function handles CAN RX1 interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void CAN_RX1_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : CAN_SCE_IRQHandler
* Description    : This function handles CAN SCE interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void CAN_SCE_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : EXTI9_5_IRQHandler
* Description    : This function handles External lines 9 to 5 interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void EXTI9_5_IRQHandler(void)
{
    if (EXTI_GetITStatus(EXTI_Line5) != RESET)
    {
        /* Toggle GPIO_LED pin 6 */
        //GPIO_WriteBit(GPIO_LED, GPIO_Pin_6, (BitAction)((1-GPIO_ReadOutputDataBit(GPIO_LED, GPIO_Pin_6))));
        ucILIUpdateFlag = 1;
        /* Clear the I2C_INT EXTI line pending bit */
        EXTI_ClearITPendingBit(EXTI_Line5);
    }
}

/*******************************************************************************
* Function Name  : TIM1_BRK_IRQHandler
* Description    : This function handles TIM1 Break interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_BRK_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : TIM1_UP_IRQHandler
* Description    : This function handles TIM1 overflow and update interrupt 
*                  request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_UP_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : TIM1_TRG_COM_IRQHandler
* Description    : This function handles TIM1 Trigger and commutation interrupts 
*                  requests.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_TRG_COM_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : TIM1_CC_IRQHandler
* Description    : This function handles TIM1 capture compare interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_CC_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : TIM2_IRQHandler
* Description    : This function handles TIM2 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void TIM2_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : TIM3_IRQHandler
* Description    : This function handles TIM3 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void TIM3_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : TIM4_IRQHandler
* Description    : This function handles TIM4 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void TIM4_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : I2C1_EV_IRQHandler
* Description    : This function handles I2C1 Event interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void I2C1_EV_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : I2C1_ER_IRQHandler
* Description    : This function handles I2C1 Error interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void I2C1_ER_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : I2C2_EV_IRQHandler
* Description    : This function handles I2C2 Event interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void I2C2_EV_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : I2C2_ER_IRQHandler
* Description    : This function handles I2C2 Error interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void I2C2_ER_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : SPI1_IRQHandler
* Description    : This function handles SPI1 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void SPI1_IRQHandler(void)
{
    uint i;
    uchar ucSPIReceByte;
    if (SPI_I2S_GetITStatus(SPI1, SPI_I2S_IT_RXNE) != RESET)
    {
        ///* Send SPI1 data */
        //SPI_I2S_SendData(SPI1, SPI1_Buffer_Tx[TxIdx++]);

        ///* Disable SPI1 TXE interrupt */
        //if (TxIdx == BufferSize)
        //{
        //  SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_TXE, DISABLE);
        //}
        //SPI2_Buffer_Rx[RxIdx++] = SPI_I2S_ReceiveData(SPI1);
        ucSPIReceByte = SPI1->DR; //SPI_I2S_ReceiveData(SPI1);
        if (ucSPIRxSta == 0)
        { //
            //update the next answer byte
            SPI1->DR = 0x00; //SPI_I2S_SendData(SPI1,0);
            //find command
            ucSPIRxCmd = ucSPIReceByte & 0x1f;
            if (ucSPIRxCmd == 2)
            { //read the scan data
                ucSPIRxSta = 1;
                //
                if (ucTouchMaskFlag == 0)
                {
                    ucTouchSta = ucTouchStaLock;
                    usTouchX = usTouchXLock;
                    usTouchY = usTouchYLock;
                    ucTouchUpdateFlag = 0;
                }
                //
                ucSPITxTotalCnt = 69; //73-4
                ucSPITxBuff[0] = 0x02;
                ucSPITxBuff[1] = 0x42;               //length
                ucSPITxBuff[2] = 0x00;               //
                ucSPITxBuff[3] = (ucSPIRunCnt << 6); //count
                ucSPIRunCnt++;
                ucSPIRunCnt %= 4;
                ucSPITxBuff[4] = 0x00;       //
                ucSPITxBuff[5] = 0x00;       //
                ucSPITxBuff[6] = ucTouchSta; //0x00; //number of touchs
                //touchs ID 0
                ucSPITxBuff[7] = usTouchX >> 8;
                ucSPITxBuff[8] = usTouchX;
                ucSPITxBuff[9] = usTouchY >> 8;
                ucSPITxBuff[10] = usTouchY;
                ucSPITxBuff[11] = 0;
                ucSPITxBuff[12] = 0;
                //Touch id 1~9
                for (i = 0; i < 9; i++)
                {
                    ucSPITxBuff[13 + i * 6] = 0;
                    ucSPITxBuff[14 + i * 6] = 0;
                    ucSPITxBuff[15 + i * 6] = 0;
                    ucSPITxBuff[16 + i * 6] = 0;
                    ucSPITxBuff[17 + i * 6] = 0;
                    ucSPITxBuff[18 + i * 6] = 0;
                }
                //button update
                if (ucButtonMaskFlag == 0)
                {
                    ucButtonSta = ucButtonStaLock;
                    ucButtonUpdateFlag = 0;
                }
                ucSPITxBuff[67] = ucButtonSta;
                ucSPITxBuff[68] = 0XAA;
            }
            else if (ucSPIRxCmd == 4)
            { //read the system data
                ucSPIRxSta = 1;
                ucSPITxTotalCnt = 15; //19-4
                ucSPITxBuff[0] = 0x04;
                ucSPITxBuff[1] = 0x0c; //length
                ucSPITxBuff[2] = 0x08; //Fireware revision number
                ucSPITxBuff[3] = 0x00;
                ucSPITxBuff[4] = 0x00; //msb
                ucSPITxBuff[5] = 0x67; //lsb
                ucSPITxBuff[6] = 0x00;
                ucSPITxBuff[7] = 0x00;
                ucSPITxBuff[8] = 0x00;
                ucSPITxBuff[9] = 0x00;
                ucSPITxBuff[10] = 0x00;
                ucSPITxBuff[11] = 0x00;
                ucSPITxBuff[12] = 0x00;
                ucSPITxBuff[13] = 0x00;
                ucSPITxBuff[14] = 0xaa;
            }
            else if (ucSPIRxCmd == 8)
            { //reset chip
                ucSPIRxSta = 1;
                ucSPITxTotalCnt = 0x06; //10-4
                ucSPITxBuff[0] = 0x08;  //command
                ucSPITxBuff[1] = 0x03;  //length
                ucSPITxBuff[2] = 0x00;
                ucSPITxBuff[3] = 0x00;
                ucSPITxBuff[4] = 0x00;
                ucSPITxBuff[5] = 0xaa;
            }
            else if (ucSPIRxCmd == 9)
            { //Reinitialize baselines
                ucSPIRxSta = 1;
                ucSPITxTotalCnt = 0x06; //10-4
                ucSPITxBuff[0] = 0x09;  //command
                ucSPITxBuff[1] = 0x03;  //length
                ucSPITxBuff[2] = 0x00;
                ucSPITxBuff[3] = 0x00;
                ucSPITxBuff[4] = 0x00;
                ucSPITxBuff[5] = 0xaa;
            }
        }
        else if (ucSPIRxSta == 1)
        { //
            //update the next answer byte
            SPI1->DR = 0x00; //SPI_I2S_SendData(SPI1,0);
            if (ucSPIReceByte != 0)
            {
                ucSPIRxSta = 0; //restart
            }
            else
            {
                ucSPIRxSta = 2; //goto next state
            }
        }
        else if (ucSPIRxSta == 2)
        { //data
            //
            if (ucSPIReceByte != 0)
            {
                SPI1->DR = 0x00; //SPI_I2S_SendData(SPI1,0);  //goto restart
                ucSPIRxSta = 0;  //restart
            }
            else
            {
                SPI1->DR = 0xee; //SPI_I2S_SendData(SPI1,0xee); //send first byte
                ucSPITxCurrCnt = 0;
                ucSPIRxSta = 3; //goto next state
            }
        }
        else if (ucSPIRxSta == 3)
        { //data content
            //SPI_I2S_SendData(SPI1,0);
            if (ucSPIReceByte != 0)
            {
                SPI1->DR = 0x00; //SPI_I2S_SendData(SPI1,0);  //goto restart
                ucSPIRxSta = 0;  //restart
            }
            else
            {
                SPI1->DR = ucSPITxBuff[ucSPITxCurrCnt]; //SPI_I2S_SendData(SPI1,ucSPITxBuff[ucSPITxCurrCnt]); //send first byte
                ucSPITxCurrCnt++;
                if (ucSPITxCurrCnt >= ucSPITxTotalCnt)
                {
                    ucSPITxCurrCnt = 0;
                    ucSPIRxSta = 4; //goto next state
                }
            }
        }
        else if (ucSPIRxSta == 4)
        { //data trial
            if (ucSPIReceByte != 0)
            {
                SPI1->DR = 0x00; //SPI_I2S_SendData(SPI1,0);  //goto restart
                ucSPIRxSta = 0;  //restart
            }
            else
            {
                SPI1->DR = 0x00; //SPI_I2S_SendData(SPI1,0x00); //send first byte
                ucSPIRxSta = 0;  //goto the idle state
            }
        }
    }
}

/*******************************************************************************
* Function Name  : SPI2_IRQHandler
* Description    : This function handles SPI2 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void SPI2_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : USART1_IRQHandler
* Description    : This function handles USART1 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void USART1_IRQHandler(void)
{
    //Used for Receive data from computer ...
    uchar a;
    if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
    {
        //Need use this interrupt...
        if (USART_GetFlagStatus(USART1, USART_FLAG_ORE) || USART_GetFlagStatus(USART1, USART_FLAG_FE) || USART_GetFlagStatus(USART1, USART_FLAG_NE))
        {
            a = USART_ReceiveData(USART1);
        }
        else if (USART_GetFlagStatus(USART1, USART_FLAG_RXNE))
        {
            a = USART_ReceiveData(USART1);

            ///*
            if ((UsartRecePot(USART1_INDEX) + 1) != UsartRCurPot(USART1_INDEX))
            { // buffers is not full
                UsartReceBuff(USART1_INDEX)[UsartRecePot(USART1_INDEX)] = a;
                UsartRecePot(USART1_INDEX)++;
                UsartRecePot(USART1_INDEX) %= MASKBYTE;
            }
            else
            { // buffers full.
            }
            //*/
            //Uputchar(a,UART5_INDEX);
            //
            //Uputchar(a,UART5_INDEX);
        }
        USART_ClearITPendingBit(USART1, USART_IT_RXNE);
    }

    if (USART_GetITStatus(USART1, USART_IT_TXE) != RESET)
    {
        //Port set
        if (USART_GetFlagStatus(USART1, USART_FLAG_TXE))
        {
            //LedToggle(2);
            if (UsartSCurPot(USART1_INDEX) != UsartSendPot(USART1_INDEX))
            { //if hvae data,then send it
                //if ((USART1->SR & USART_FLAG_TC) != USART_FLAG_TC) { //
                USART_SendData(USART1, UsartSendBuff(USART1_INDEX)[UsartSendPot(USART1_INDEX)]);
                UsartSendPot(USART1_INDEX)++;
                UsartSendPot(USART1_INDEX) %= MASKBYTE;
            }
            else
            { //if no then,stop usart interrupt
                USART_ITConfig(USART1, USART_IT_TXE, DISABLE);
                //
                UsartSendFlag(USART1_INDEX) = 0;
            }
            /* Clear the USART1 transmit interrupt */
            USART_ClearITPendingBit(USART1, USART_IT_TXE);
        }
    }
}

/*******************************************************************************
* Function Name  : USART2_IRQHandler
* Description    : This function handles USART2 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void USART2_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : USART3_IRQHandler
* Description    : This function handles USART3 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void USART3_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : EXTI15_10_IRQHandler
* Description    : This function handles External lines 15 to 10 interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void EXTI15_10_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : RTCAlarm_IRQHandler
* Description    : This function handles RTC Alarm interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void RTCAlarm_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : USBWakeUp_IRQHandler
* Description    : This function handles USB WakeUp interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void USBWakeUp_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : TIM8_BRK_IRQHandler
* Description    : This function handles TIM8 Break interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void TIM8_BRK_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : TIM8_UP_IRQHandler
* Description    : This function handles TIM8 overflow and update interrupt 
*                  request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void TIM8_UP_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : TIM8_TRG_COM_IRQHandler
* Description    : This function handles TIM8 Trigger and commutation interrupts 
*                  requests.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void TIM8_TRG_COM_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : TIM8_CC_IRQHandler
* Description    : This function handles TIM8 capture compare interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void TIM8_CC_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : ADC3_IRQHandler
* Description    : This function handles ADC3 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void ADC3_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : FSMC_IRQHandler
* Description    : This function handles FSMC global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void FSMC_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : SDIO_IRQHandler
* Description    : This function handles SDIO global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void SDIO_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : TIM5_IRQHandler
* Description    : This function handles TIM5 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void TIM5_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : SPI3_IRQHandler
* Description    : This function handles SPI3 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void SPI3_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : UART4_IRQHandler
* Description    : This function handles UART4 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void UART4_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : UART5_IRQHandler
* Description    : This function handles UART5 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void UART5_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : TIM6_IRQHandler
* Description    : This function handles TIM6 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void TIM6_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : TIM7_IRQHandler
* Description    : This function handles TIM7 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void TIM7_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : DMA2_Channel1_IRQHandler
* Description    : This function handles DMA2 Channel 1 interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void DMA2_Channel1_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : DMA2_Channel2_IRQHandler
* Description    : This function handles DMA2 Channel 2 interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void DMA2_Channel2_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : DMA2_Channel3_IRQHandler
* Description    : This function handles DMA2 Channel 3 interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void DMA2_Channel3_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name  : DMA2_Channel4_5_IRQHandler
* Description    : This function handles DMA2 Channel 4 and DMA2 Channel 5
*                  interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void DMA2_Channel4_5_IRQHandler(void)
{
}

/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
